package com.freewater.springboot.demo.ioc.qualifier.registqualifier;

import org.springframework.beans.factory.annotation.CustomAutowireConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashSet;
import java.util.Set;

@Configuration
public class AppConfig {

    @Bean
    public static CustomAutowireConfigurer customAutowireConfigurer() {
        CustomAutowireConfigurer customAutowireConfigurer = new CustomAutowireConfigurer();
        Set<Class> qualifierTypes = new HashSet<>();
        qualifierTypes.add(MovieQualifier.class); // 自定义的Qualifier类，可以不用标记@Qualifier也可以
        customAutowireConfigurer.setCustomQualifierTypes(qualifierTypes);
        return customAutowireConfigurer;
    }

    @Bean
    @MovieQualifier(genre = "Action", format = Format.VHS)
    public MovieCatalog movieCatalog1() {
        return new MovieCatalog();
    }

    @Bean
    @MovieQualifier(genre = "Action", format = Format.DVD)
    public MovieCatalog movieCatalog2() {
        return new MovieCatalog();
    }

    @Bean
    public MovieRecommender movieRecommender() {
        return new MovieRecommender();
    }
}
